package com.yanghui.controller;

import com.yanghui.pojo.BlogType;
import com.yanghui.service.BlogTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@SuppressWarnings("all")
@Controller
public class BlogTypeController {
    @Autowired
    private BlogTypeService blogTypeService;


    /**
     * 查询博客所有的类别及数量
     */
    @RequestMapping("/selectBlogType")
    @ResponseBody
    public Map<String,Object> selectBlogType() {
        Map<String,Object> map = new HashMap<>();
        List<BlogType> blogTypeList = blogTypeService.selectBlogType();
        /** 查询成功 */
        if (blogTypeList.size() > 0) {
            map.put("status", 200);
        } else {
            map.put("status", 500);
        }
        map.put("blogTypeList", blogTypeList);

        return map;
    }
}
